/**
 * [OElove Webapp] (C)2010-2099 oelove.com Inc.
 * Email: service@phpcoo.com，phpcoo@qq.com
 * This is not a freeware, use is subject to license terms
 * $ LastTime 2017.02.08 Update by CL $
*/
$(function(){

	//撤销邀请
	$(document).on("click", "[f='but_yueta_cancel']", function(){
		$_id = $(this).attr("data-id");
		$_url = _ROOT_PATH+"index.php?m=user&c=yueta&a=cancel&id="+$_id;
		oeAjaxConfirmBox($_url, "确定要取消邀请吗？", function(){
			window.location.reload();
		});
	});

	//查看联系方式
	$(document).on("click", "[f='but_view_contact']", function(){
		$_id = $(this).attr("data-id");
		$width = $(this).attr("data-width");
		if (typeof($width) == "undefined") {
			$width = 500;
		}
		$height = $(this).attr("data-height");
		if (typeof($height) == "undefined") {
			$height = 380;
		}
		$_url = _ROOT_PATH+"index.php?m=user&c=yueta&a=viewcontact&id="+$_id+"&r="+get_rndnum(8);
		oeShadeBox("pop_yueta_viewcontact", "ajax", $_url, $width, $height);
	});

	//申请退款
	$(document).on("click", "[f='but_app_refund']", function(){
		$_id = $(this).attr("data-id");
		$width = $(this).attr("data-width");
		if (typeof($width) == "undefined") {
			$width = 550;
		}
		$height = $(this).attr("data-height");
		if (typeof($height) == "undefined") {
			$height = 460;
		}
		$_url = _ROOT_PATH+"index.php?m=user&c=yueta&a=refund&id="+$_id+"&r="+get_rndnum(8);
		oeShadeBox("pop_refund_yueta", "ajax", $_url, $width, $height);
	});

	//提交申请
	$(document).on("click", "[f='but_save_apprefund']", function(){
		$_yueid = $(this).attr("data-id");
		$_idrz = $(this).attr("data-idrz");
		if ($_idrz == "0") {
			ToastShow("对不起，您还没实名认证，不能申请退款！");
			return false;
		}
		$bankname = $("#bankname").val();
		$banksub = $("#banksub").val();
		$bankaccount = $("#bankaccount").val();
		$payword = $("#payword").val();
		if ($bankname.length == 0) {
			ToastShow("请填写收款开户行");
			return false;
		}
		if ($bankaccount.length == 0) {
			ToastShow("请填写收款人账号");
			return false;
		}
		if ($payword.length == 0) {
			ToastShow("请输入安全密码");
			return false;
		}
		$.ajax({
			type: "POST",
			url: _OE_FILE+"&c=yueta",
			cache: false,
			data: {
					a:"saveapp", id:$_yueid, bankname:$bankname, banksub:$banksub, 
					bankaccount:$bankaccount, payword:$payword, r:get_rndnum(8)
			},
			dataType: "json",
			success: function($data) {
				$json = eval($data);
				$response = $json.response;
				$result = $json.result;
				if ($response == "1") {
					ToastShow("申请成功，请等待网站处理");
					setTimeout(function(){
						window.location.reload();
					}, 500);
				}
				else {
					$_error = $result;
					if ($_error.length == 0) {
						$_error = "申请失败，请检查";
					}
					ToastShow($_error);
				}
			},
			error: function() {
				ToastShow("系统繁忙，请稍后再试");
			}
		});

	});

	//显示隐藏提示
	$(document).on("mouseover", "[f='but_show_refundtips']", function(){
		if ($(this).find("span").css("display") == "none") {
			$(this).find("span").show();
		}
	});
	$(document).on("mouseout", "[f='but_show_refundtips']", function(){
		if ($(this).find("span").css("display") == "block") {
			$(this).find("span").hide();
		}
	});

	
});
